﻿using Microsoft.EntityFrameworkCore;
using MyWeb.ServiceBus.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace MyWeb.ServiceBus.Services
{
    public interface IBaseService<Entity> where Entity : class
    {
        /// <summary>
        /// 异步新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<long> AddAsync(Entity t);
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        long Add(Entity t);
        /// <summary>
        /// 异步删除
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<int> DeleteAsync(Entity t);
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        int Delete(Entity t);
        /// <summary>
        /// 异步编辑
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<int> EditAsync(Entity t);
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        int Edit(Entity t);

        /// <summary>
        /// 异步查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<List<Entity>> QueryAsync(Expression<Func<Entity, bool>> where);
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        List<Entity> Query(Expression<Func<Entity, bool>> where);
        /// <summary>
        /// 异步分页查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        Task<List<Entity>> QueryPageAsync(out long count, int page = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        List<Entity> QueryPage(out long count, int page = 1, int pageSize = 20);
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        List<Entity> QueryPage(Expression<Func<Entity, bool>> where, out long count, int page = 1, int pageSize = 20);

    }
}
